/*
  利用数组返回值输出最值
 */

import java.util.Scanner;

public class MothodDemo061 {
    public static void main(String[] args) {
        //建立输入
        Scanner sc = new Scanner(System.in);
        int arr[] = new int[6];
        //循环录入
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个数字:");
            arr[i] = sc.nextInt();
        }
        int[] maxAndMin = getMaxAndMin(arr);
        System.out.println("最大值为:" + maxAndMin[0]);
        System.out.println("最小值为:" + maxAndMin[1]);

    }

    public static int[] getMaxAndMin(int arr[]) {
        int max = arr[0];
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        int[] maxAndmin = {max, min};
        return maxAndmin;
    }
}
